.equ     MEM_CTL_BASE,	0x48000000
.equ     SDRAM_BASE,	0x30000000
.text
.global _start
_start:
	bl		disable_wd
	bl		setupmem
	bl		copysteppingstone_to_sdram
	ldr		pc,		=on_sdram//????????
on_sdram:
	ldr 	sp, 	=0x34000000 @设置堆栈
	bl 		main			@调用C程序中的main
halt_loop:
	b halt_loop

disable_wd:
	ldr		r0, 	=0x56000010 @WATCHDOG寄存器地址
	mov 	r1,		#0x0
	str 	r1,		[r0]		@写入0，禁止WATCHDOG，否则CPU不断重启
	mov 	pc,		lr
	
setupmem:
	mov		r0,		#MEM_CTL_BASE
	adrl	r1,		mem_cfg_value
	add		r2,		r1,	#4*13
l:
	ldr		r3,		[r1],	#4
	str		r3,		[r0],	#4
	cmp		r2,		r1 
	bne		lb
	mov		pc,		lr

copysteppingstone_to_sdram:
	ldr 	r0,		=SDRAM_BASE
	mov 	r1,		#0x0
	mov		r2,		#4*1024
l:	
	ldr		r3,		[r1],	#4
	str		r3,		[r0],	#4
	cmp		r1,		r2
	bne		bl	
	mov		pc,		lr
	
.align	4
mem_cfg_value:
	.long  
